An improved algorithm to reconstruct a binary tree from its inorder and postorder traversals
نویسندگان
چکیده مقاله:
It is well-known that, given inorder traversal along with one of the preorder or postorder traversals of a binary tree, the tree can be determined uniquely. Several algorithms have been proposed to reconstruct a binary tree from its inorder and preorder traversals. There is one study to reconstruct a binary tree from its inorder and postorder traversals, and this algorithm takes running time of $ BigO{emph{n}^2} $. In this paper, we present $ proc{InPos} $ an improved algorithm to reconstruct a binary tree from its inorder and postorder traversals. The running time and space complexity of the algorithm are an order of $ BigTheta{emph{n}} $ and $ BigTheta{emph{n}} $ respectively, which we prove to be optimal. The $ proc{InPos} $ algorithm not only reconstructs the binary tree, but also it determines different types of the nodes in a binary tree; nodes with two children, nodes with one child, and nodes with no child. At the end, the $ proc{InPos} $ returns a matrix-based structure to represent the binary tree, and enabling access to any structural information of the reconstructed tree in linear time with any given tree traversals.
منابع مشابه
A novel algorithm to determine the leaf (leaves) of a binary tree from its preorder and postorder traversals
Binary trees are essential structures in Computer Science. The leaf (leaves) of a binary tree is one of the most significant aspects of it. In this study, we prove that the order of a leaf (leaves) of a binary tree is the same in the main tree traversals; preorder, inorder, and postorder. Then, we prove that given the preorder and postorder traversals of a binary tree, the leaf (leaves) of a bi...
متن کاملConstructing a binary tree efficiently from its traversals
In this note we streamline an earlier algorithm for constructing a binary tree from its inorder and preorder traversals. The new algorithm is conceptually simpler than the earlier algorithms and its time complexity has a smaller constant factor.
متن کاملIterative Method for Recreating a Binary Tree from its Traversals
Many reconstruction algorithms for binary tree have been discussed in this paper. A particular focus of this paper is on “A new Non-Recursive Algorithm for Reconstructing a Binary Tree from its Traversals”. The computation time required for executing the reconstruction algorithm are O(N) and space complexity is O(NlogN) where N is the number of nodes in the binary tree. This algorithm works wel...
متن کاملReconstructing a Binary Tree from its Traversals in Doubly
We consider the following problem. For a binary tree T = (V; E) where V = f1; 2; :::; ng, given its inorder traversal and either its preorder or its postorder traversal, reconstruct the binary tree. We present a new parallel algorithm for this problem. Our algorithm requires O(n) space. The main idea of our algorithm is to reduce the reconstruction process to merging two sorted sequences. With ...
متن کاملthe aesthetic dimension of howard barkers art: a frankfurtian approach to scenes from an execution and no end of blame
رابطه ی میانِ هنر و شرایطِ اجتماعیِ زایش آن همواره در طولِ تاریخ دغدغه ی ذهنی و دل مشغولیِ اساسیِ منتقدان و نیز هنرمندان بوده است. از آنجا که هنر در قفس آهنیِ زندگیِ اجتماعی محبوس است، گسترش وابستگیِ آن با نهاد ها و اصولِ اجتماعی پیرامون، صرفِ نظر از هم سو بودن و یا غیرِ هم سو بودنِ آن نهاد ها، امری اجتناب ناپذیر به نظر می رسد. با این وجود پدیدار گشتنِ چنین مباحثِ حائز اهمییتی در میان منتقدین، با ظهورِ مکتب ما...
منابع من
با ذخیره ی این منبع در منابع من، دسترسی به آن را برای استفاده های بعدی آسان تر کنید
ذخیره در منابع من قبلا به منابع من ذحیره شده{@ msg_add @}
عنوان ژورنال
دوره 49 شماره 1
صفحات 93- 113
تاریخ انتشار 2017-06-01
با دنبال کردن یک ژورنال هنگامی که شماره جدید این ژورنال منتشر می شود به شما از طریق ایمیل اطلاع داده می شود.
میزبانی شده توسط پلتفرم ابری doprax.com
copyright © 2015-2023